package math;

public class UnaryOperatorNode implements MathNode
{
    String operator;
    MathNode operand;

    public UnaryOperatorNode(String operator,MathNode operand)
    {
        this.operator = operator;
        this.operand = operand;
    }

    @Override
    public String getExpressionString()
    {
        if(operator.charAt(0) == '!')
        {
            return operand.getExpressionString() + operator;
        }
        else
        {
            return operator + operand.getExpressionString();
        }
    }

    @Override
    public String getName()
    {
        return operator;
    }

    @Override
    public String toString()
    {
        return getClass().getName() + "<operator=" + operator + ",operand=" + operand.getExpressionString() + ">";
    }
}
